package org.zxp.tools;

public class ReplaceSql {
    public static void main(String[] args) {
        String text = "select count(1) FROM flamingo_mcn_account_inc inc left join flamingo_mcn_account ma on inc.ACCOUNT_ID=ma.ACCOUNT_ID WHERE inc.DATA_DAY = DATE_SUB(CURDATE(),INTERVAL 1 DAY) and inc.account_id in ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) and inc.company_id in ( ? , ? , ? , ? , ? , ? , ? ) and ma.IS_UPDATE = 1 ";
        String param = "1000314(Long), 1000315(Long), 1000316(Long), 1000317(Long), 1000318(Long), 1000319(Long), 1000320(Long), 1000321(Long), 1000322(Long), 1000323(Long), 1000350(Long), 1000354(Long), 1000538(Long), 1000540(Long), 1000541(Long), 1000543(Long), 1000561(Long), 1000562(Long), 1000564(Long), 1000569(Long), 1000570(Long), 1000571(Long), 1000573(Long), 2(String), 3(String), 7(String), 6(String), 4(String), 8(String), 9(String)";
        String[] repEmpltyList = {"\\(Timestamp\\)","\\(String\\)","\\(Integer\\)","\\(Integer\\)","\\(Long\\)"};
        for (int i = 0; i < repEmpltyList.length; i++) {
            param = param.replaceAll(repEmpltyList[i],"");
        }
        String[] split = param.split(", ");
        for (int i = 0; i < split.length; i++) {
            if(split[i].equals("null")){
                text = text.replaceFirst(" [?]","null");
            }else{
                text = text.replaceFirst(" [?]","'"+split[i]+"'");
            }
        }
        System.out.println(text);
    }

}
